home *** CD-ROM | disk | FTP | other *** search
/ Better Homes & Gardens: …oking for Today - Chicken / Image.iso / pc / shared.dxr / 01004_DB scripts.ls < prev    next >
Encoding:
Text File  |  1995-11-21  |  9.2 KB  |  303 lines

  1. on DBSetUp
  2.   global gDBSearchFile, gHardDriveP, gDBSearchPath, gOriginPath, gDBRecipeID, gDBTitle, gDBChapter, gDBServings, gDBPrepTime, gDBDishType, gDBIngredient, gDBInstruction, gDBInstructionType, gDBBeauty, gDBRamble, gDBDescription, gDBSubTitle, gDBAuthorName, gDBOriginalBook, gDBOrganization, gDBCity, gDBState, gDBCalories, gDBCholesterol, gDBCarbohydrates, gDBProtein, gDBSodium, gDBFat, gDBSaturated, gDBPotassium, gDBEvent1, gDBEvent2, gDBEvent3, gDBEvent4, gDBQuantity, gDBUnit, gDBNoQuantity, gDBCollate, gDBVideoLinks, gDBTermID, gDBTermName, gDBTermDefinition, gDBTermLinks, gDBTermPhotoID, gDBTermPhotoFile, gDBPhotoTitle, gDBPhotoCaption, gDBNutritionID, gDBNutritionFood, gDBNutritionUnit, gDBNutritionList, gDBUtensilID, gDBUtensilName, gDBUtensilText, gDBTableText, gDBSearchMenu, gDBSearchIngredient, gDBResult, gGRkeyID, gGRDBNum, gDBSearchIngredients, gDBSearchMenus, gDBMenuIDs, gDBMenuTypes
  3.   if gHardDriveP then
  4.     set gDBSearchPath to gOriginPath
  5.   else
  6.     set gDBSearchPath to the pathName
  7.   end if
  8.   set gDBRecipeID to 0
  9.   set gDBChapter to 1
  10.   set gDBTitle to 2
  11.   set gDBPrepTime to 2001
  12.   set gDBDishType to 9001
  13.   set gDBInstruction to 20005
  14.   set gDBIngredient to 20006
  15.   set gDBInstructionType to 3001
  16.   set gDBBeauty to 1001
  17.   set gDBRamble to 20001
  18.   set gDBDescription to 20002
  19.   set gDBAuthorName to 6
  20.   set gDBOriginalBook to 7
  21.   set gDBOrganization to 8
  22.   set gDBCity to 9
  23.   set gDBState to 10
  24.   set gDBSubTitle to 3
  25.   set gDBServings to 12
  26.   set gDBCalories to 13
  27.   set gDBCholesterol to 14
  28.   set gDBCarbohydrates to 15
  29.   set gDBProtein to 16
  30.   set gDBSodium to 17
  31.   set gDBFat to 18
  32.   set gDBSaturated to 19
  33.   set gDBPotassium to 20
  34.   set gDBEvent1 to 23
  35.   set gDBEvent2 to 20
  36.   set gDBEvent3 to 21
  37.   set gDBEvent4 to 22
  38.   set gDBQuantity to 4001
  39.   set gDBUnit to 4002
  40.   set gDBNoQuantity to 4003
  41.   set gDBCollate to 4004
  42.   set gDBVideoLinks to 20000
  43.   set gDBTermID to 5000
  44.   set gDBTermName to 5001
  45.   set gDBTermDefinition to 20003
  46.   set gDBTermLinks to 20004
  47.   set gDBTermPhotoID to 6000
  48.   set gDBTermPhotoFile to 6001
  49.   set gDBPhotoTitle to 6002
  50.   set gDBPhotoCaption to 20004
  51.   set gDBNutritionID to 7000
  52.   set gDBNutritionFood to 7001
  53.   set gDBNutritionUnit to 7002
  54.   set gDBNutritionList to [7003, 7004, 7005, 7006, 7007, 7008, 7009, 7010, 7011]
  55.   set gDBUtensilID to 8000
  56.   set gDBUtensilName to 8001
  57.   set gDBUtensilText to 20007
  58.   set gDBTableText to 20000
  59.   set gDBSearchMenu to 20002
  60.   set gDBSearchIngredient to 20006
  61.   set gDBResult to 0
  62.   set gGRkeyID to 0
  63.   set gGRDBNum to 0
  64.   set gDBSearchIngredients to []
  65.   set gDBSearchMenus to []
  66.   set gDBMenuIDs to [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
  67.   set gDBMenuTypes to ["fat": "Low: < 3 g", "saturated": "Low: < 1 g", "sodium": "Low: < 140 mg", "sodium": "Very low: < 35 mg", "calories": "Low: < 40", "carbohydrates": "Good source: > 30 g", "carbohydrates": "High in: > 60 g", "cholesterol": "Low: < 20 mg", "potassium": "Good source: > 330 mg", "potassium": "High in: > 700 mg", EMPTY: EMPTY, EMPTY: EMPTY, EMPTY: EMPTY, EMPTY: EMPTY, "times": "Less than 15 minutes", "times": "Less than 30 minutes", "times": "Less than 1 hour", "times": "Less than 2 hours", "times": "Less than 4 hours", "dishes": "Appetizers & Snacks", "dishes": "Main Dishes", "dishes": "Side Dishes, Breads & Rolls", "dishes": "Soups, Salads & Sandwiches", "dishes": "Desserts & Beverages"]
  68. end
  69.  
  70. on dbNum dbName
  71.   if dbName = "recipe" then
  72.     set dbNum to 0
  73.   else
  74.     if dbName = "beauty" then
  75.       set dbNum to 1000
  76.     else
  77.       if dbName = "prep time" then
  78.         set dbNum to 2000
  79.       else
  80.         if dbName = "instruction" then
  81.           set dbNum to 3000
  82.         else
  83.           if dbName = "ingredient" then
  84.             set dbNum to 4000
  85.           else
  86.             if dbName = "terms" then
  87.               set dbNum to 5000
  88.             else
  89.               if dbName = "term photo" then
  90.                 set dbNum to 6000
  91.               else
  92.                 if dbName = "nutrition" then
  93.                   set dbNum to 7000
  94.                 else
  95.                   if dbName = "utensil" then
  96.                     set dbNum to 8000
  97.                   else
  98.                     if dbName = "dish type" then
  99.                       set dbNum to 9000
  100.                     else
  101.                       if dbName = "tables" then
  102.                         set dbNum to 10000
  103.                       else
  104.                         if dbName = "personal recipe" then
  105.                           set dbNum to 3000
  106.                         else
  107.                           if dbName = "personal category" then
  108.                             set dbNum to 5000
  109.                           else
  110.                             if dbName = "meal plan" then
  111.                               set dbNum to 14000
  112.                             else
  113.                               set dbNum to dbName
  114.                             end if
  115.                           end if
  116.                         end if
  117.                       end if
  118.                     end if
  119.                   end if
  120.                 end if
  121.               end if
  122.             end if
  123.           end if
  124.         end if
  125.       end if
  126.     end if
  127.   end if
  128.   return dbNum
  129. end
  130.  
  131. on dbBeginSession
  132.   global gDBObject, gDBResult, gDBSearchPath
  133.   DBEndSession()
  134.   if the machineType = 256 then
  135.     openXLib("DBWidget.DLL")
  136.     set gDBObject to DBWidget(mnew)
  137.     set dbPath to gDBSearchPath & "PCDB\FULLDB"
  138.   else
  139.     openXLib("DBWidget")
  140.     set gDBObject to DBWidget(mnew)
  141.     set dbPath to the pathName & "MACDB:FULLDB"
  142.   end if
  143.   set gDBResult to gDBObject(mOpenDB, dbPath, 1)
  144.   return gDBResult
  145. end
  146.  
  147. on DBBeginSaveSession
  148.   global gDBObject, gDBResult, gOriginPath
  149.   DBEndSession()
  150.   if the machineType = 256 then
  151.     openXLib("DBWidget.DLL")
  152.     set gDBObject to DBWidget(mnew)
  153.     set dbPath to gOriginPath & "DATA\USERDB"
  154.   else
  155.     openXLib("DBWidget")
  156.     set gDBObject to DBWidget(mnew)
  157.     set dbPath to gOriginPath & "DATA:USERDB"
  158.   end if
  159.   set gDBResult to gDBObject(mOpenDB, dbPath, 2)
  160.   return gDBResult
  161. end
  162.  
  163. on DBBeginSearchSession
  164.   global gDBObject, gDBResult, gOriginPath
  165.   DBEndSession()
  166.   if the machineType = 256 then
  167.     openXLib("DBWidget.DLL")
  168.     set gDBObject to DBWidget(mnew)
  169.     set dbPath to gOriginPath & "DATA\SRCHDB"
  170.   else
  171.     openXLib("DBWidget")
  172.     set gDBObject to DBWidget(mnew)
  173.     set dbPath to gOriginPath & "DATA:SRCHDB"
  174.   end if
  175.   set gDBResult to gDBObject(mOpenDB, dbPath, 3)
  176.   return gDBResult
  177. end
  178.  
  179. on DBBeginBothSession
  180.   global gDBObject, gDBResult, gOriginPath
  181.   DBEndSession()
  182.   if the machineType = 256 then
  183.     openXLib("DBWidget.DLL")
  184.     set gDBObject to DBWidget(mnew)
  185.     set dbPath to the pathName & "PCDB\FULLDB"
  186.   else
  187.     openXLib("DBWidget")
  188.     set gDBObject to DBWidget(mnew)
  189.     set dbPath to the pathName & "MACDB:FULLDB"
  190.   end if
  191.   set gDBResult to gDBObject(mOpenDB, dbPath, 1)
  192.   if the machineType = 256 then
  193.     set dbPath to gOriginPath & "DATA\USERDB"
  194.   else
  195.     set dbPath to gOriginPath & "DATA:USERDB"
  196.   end if
  197.   set gDBResult to gDBObject(mOpenDB, dbPath, 2)
  198.   return gDBResult
  199. end
  200.  
  201. on DBEndSession
  202.   global gDBObject
  203.   if objectp(gDBObject) then
  204.     gDBObject(mdispose)
  205.   end if
  206. end
  207.  
  208. on DBGetRecord keyID, dbName
  209.   global gDBObject, gDBResult, gGRkeyID, gGRDBNum
  210.   set dbNum to dbNum(dbName)
  211.   set gDBResult to gDBObject(mGetDBRecord, integer(keyID), dbNum, 1)
  212.   if gDBResult = 2 then
  213.     set gGRkeyID to keyID
  214.     set gGRDBNum to dbNum
  215.   end if
  216.   return gDBResult
  217. end
  218.  
  219. on DBNextRecord dbName
  220.   global gDBObject, gDBResult
  221.   set dbNum to dbNum(dbName)
  222.   set gDBResult to gDBObject(mNextDBRecord, dbNum, 1)
  223.   return gDBResult
  224. end
  225.  
  226. on DBGetField fieldNum
  227.   global gDBObject, gDBResult, gGRkeyID, gGRDBNum
  228.   if gDBResult = 0 then
  229.     return gDBObject(mGetDBField, fieldNum, 1)
  230.   else
  231.     return 0
  232.   end if
  233. end
  234.  
  235. on DBStartSearch keyID, fieldNum
  236.   global gDBObject, gDBResult
  237.   if gDBResult >= 0 then
  238.     set gDBResult to gDBObject(mStartDBSearch, integer(keyID), fieldNum, 3)
  239.   end if
  240.   return gDBResult
  241. end
  242.  
  243. on DBAddSearch keyID, fieldNum
  244.   global gDBObject, gDBResult
  245.   if gDBResult >= 0 then
  246.     set gDBResult to gDBObject(mAddDBSearch, integer(keyID), fieldNum, 3)
  247.   end if
  248.   return gDBResult
  249. end
  250.  
  251. on DBGetResult num
  252.   global gDBObject, gDBResult
  253.   if gDBResult > 0 then
  254.     set gDBResult to gDBObject(mGetDBResults, num, 3)
  255.     return gDBResult
  256.   else
  257.     return 0
  258.   end if
  259. end
  260.  
  261. on DBSetRecord dbName, aString
  262.   global gDBObject, gDBResult
  263.   set dbNum to dbNum(dbName)
  264.   if gDBResult >= 0 then
  265.     set gDBResult to gDBObject(mSetDBRecord, dbNum, aString, 2)
  266.   end if
  267.   return gDBResult
  268. end
  269.  
  270. on DBGetSetRecord keyID, dbName
  271.   global gDBObject, gDBResult, gGRkeyID, gGRDBNum
  272.   set dbNum to dbNum(dbName)
  273.   set gDBResult to gDBObject(mGetDBRecord, integer(keyID), dbNum, 2)
  274.   return gDBResult
  275. end
  276.  
  277. on DBNextSetRecord dbName
  278.   global gDBObject, gDBResult
  279.   set dbNum to dbNum(dbName)
  280.   if gDBResult >= 0 then
  281.     set gDBResult to gDBObject(mNextDBRecord, dbNum, 2)
  282.   end if
  283.   return gDBResult
  284. end
  285.  
  286. on DBGetSetField fieldNum
  287.   global gDBObject, gDBResult, gGRkeyID, gGRDBNum
  288.   if gDBResult = 0 then
  289.     return gDBObject(mGetDBField, integer(fieldNum), 2)
  290.   else
  291.     return 0
  292.   end if
  293. end
  294.  
  295. on DBDeleteRecord dbName, fieldID
  296.   global gDBObject, gDBResult
  297.   set dbNum to dbNum(dbName)
  298.   if gDBResult >= 0 then
  299.     set gDBResult to gDBObject(mDeleteDBRecord, dbNum, integer(fieldID), 2)
  300.   end if
  301.   return gDBResult
  302. end
  303.